//
//  TCMessageCell.m
//  陶瓷
//
//  Created by 王戈 on 15/7/27.
//  Copyright (c) 2015年 王戈. All rights reserved.
//

#import "TCMessageCell.h"

@interface TCMessageCell ()

@property (nonatomic, strong) UIView *grayLine;

@end

@implementation TCMessageCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifier = @"MessageCell";
    
    TCMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[TCMessageCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupChildView];
    }
    return self;
}

- (void)setupChildView {
    _grayLine = [[UIView alloc] init];
    _grayLine.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_grayLine];

    self.detailTextLabel.textColor = [UIColor grayColor];
}

- (void)setModelArray:(NSArray *)modelArray {
    _modelArray = modelArray;
    
    self.imageView.image = [UIImage imageNamed:modelArray[2]];
    self.detailTextLabel.text = modelArray[1];
    self.textLabel.text = modelArray[0];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(0, 0, 6, self.height);
    self.textLabel.frame = CGRectMake(30, 0, self.width - 30, 25);
    self.detailTextLabel.frame = CGRectMake(30, 25, self.width - 30, 19);
    _grayLine.frame = CGRectMake(0, self.height - 0.5, self.width, 0.5);
}
@end
